<?php 
class user_login 
{ 
	function login_in() 
	{ 
		global $mysql_conn,$v_file;
		$sql = "SELECT * from `web` WHERE `web_isset` = '1';";
		$result = mysql_query($sql,$mysql_conn);
		@$row=mysql_fetch_array($result);
		$web_id = $row['web_id'];
		$web_bot = $row['web_bot'];
		$web_name = $row['web_name'];
		$web_url = $row['web_url'];
		$web_title = $row['web_title'];
		$web_keywords = $row['web_keywords'];
		$web_description = $row['web_description'];
		$web_company = $row['web_company'];
		$web_copyright = $row['web_copyright'];
		$web_isset = $row['web_isset'];
		require($v_file);
	}
	function login_do() 
	{ 
		global $mysql_conn;
		$user_name = $_POST['user_name'];
		$user_password = $_POST['user_password'];
		$sql = "SELECT * from `user` WHERE `user_name` = '".$user_name."'";
		$result = mysql_query($sql,$mysql_conn);
		@$row = mysql_fetch_array($result);
		if (!empty($row)) {
			if ($user_password == $row['user_password']) {
				$user_id = $row['user_id'];
				$user_type = $row['user_type'];
				setcookie("user_id", $user_id, time()+3600);
				setcookie("user_name", $user_name, time()+3600);
				setcookie("user_type", $user_type, time()+3600);
				$sql = "SELECT * from `user_type` WHERE `type_id` = '".$user_type."'";
				$result = mysql_query($sql,$mysql_conn);
				@$row = mysql_fetch_array($result);
				$type_name = $row['type_name'];
				setcookie("type_name", $type_name, time()+3600);
				echo "3";//密码正确
			} else {
				echo "2";//密码不正确
			}
		} else {
			echo  "1";//用户不存在
		}
	}
	function login_exit() 
	{ 
		setcookie('user_id','',time()-3600);
		setcookie('user_name','',time()-3600);
		setcookie('user_type','',time()-3600);
		setcookie('type_name','',time()-3600);
		echo "1";
	}
} 
/* End of file democontroller.php */ 